<?php

class AjaxTest extends Controller {
    
	function setVars()
	{
        define('URI',$this->uri->segment(1).'/'.$this->uri->segment(2));
		$this->tpl['title'] = "PQuery";
		$this->tpl['link'] = anchor(URI.'/ajaxdemo', 'Basic').' | ';
        $this->tpl['link'] .= anchor(URI.'/eventsdemo', 'Events').' | ';
        $this->tpl['link'] .= anchor(URI.'/effectsdemo', 'Effects').' | ';
        $this->tpl['head'] = '';
        $this->tpl['menu'] = '';
        $this->tpl['sidebar'] = '';
        
        $this->tpl['controller_url'] = site_url(URI).'/';
        $this->tpl['tpljs'][]  = 'jquery';
        $this->tpl['tplcss'][]  = 'calendar';
        $this->tpl['tpljs'][]  = 'calendar';
        $this->tpl['tpljs'][]  = 'jquery.bgiframe.min';
        $this->tpl['tpljs'][]  = 'jquery.dimensions';
        $this->tpl['tplcss'][]  = 'jquery.autocomplete';
        $this->tpl['tpljs'][]  = 'jquery.autocomplete';
        $this->tpl['tpljs'][]  = 'postcode';
        
        $this->uid = 1;
        $this->dbtable = 'agendas';
	}
    
    
    function __construct() 
	{
		parent::Controller();
        $this->auth->CheckTaMeR(101);
		$this->load->library('pquery');
		$this->setVars();
	}
	
	function index()
	{
		$this->load->view('blank',$this->tpl);
	}
	
	// Ajax demos 
	
	function ajaxdemo()
	{
        $this->load->view('test/ajax_page',$this->tpl);
	}
	
	function ajaxtime()
	{
		echo 'Time : '.date("r",time());
	}
    
	function ajaxlinkc()
	{
		echo 'Ajax link Clicked (callback)';
	}
	
	function ajaxlink()
	{
		echo 'Ajax link Clicked';
	}
	
	function ajax()
	{
		echo 'Ajax Form Submitted<br />Field :'.$this->input->post('field');
	}
	
	// Effects Demo
	
	function effectsdemo()
	{
		$this->load->view('test/effects_page',$this->tpl);
	}
	
	// Events Demo
	
	function eventsdemo()
	{
		$this->tpl['site_url']=base_url().index_page().'/';
        $this->load->view('test/events_page',$this->tpl);
	}
	
	function validate()
	{
        $email = $this->input->post('email');
        if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) echo '<font color="GREEN">Valid</font>';
		else echo '<font color="RED">Invalid</font>';
	}
}
?>
